//发现--每日推荐
import React from 'react'
import { List ,NavBar} from 'antd-mobile';
import {Icon} from 'antd'
import './index.css'
import Axios from 'axios';
const Item=List.Item;
const Brief=Item.Brief;
export default class Recommend extends React.Component{
  constructor(props){
    super(props)
    this.state={
      songList:[]
    }
  }
  componentWillMount(){
    Axios.post('http://localhost:8000/login/status?timestap='+Date.now()).then(({data})=>{
      console.log('a')
      Axios.post('http://localhost:8000/recommend/songs?timestap='+Date.now()).then(({data})=>{  
        this.setState({
          songList:data.recommend
        })
      }).catch(res=>{
        console.log(res)
      })
    }).catch(res=>{
      console.log(res)
    })
    
  }
  render(){
    console.log(this.state.songList)
    return (
      <div>
        <NavBar
            mode="light"
            icon={<Icon type="left" />}
            onLeftClick={()=>window.location.href='/'}></NavBar>
        <List className='songList'>
          {this.state.songList.map((item,i)=>{
            return <Item thumb={item.album.artist.picUrl} extra={<Icon type='more'/>}
                  onClick={() => {}}
                >{item.name} <Brief>{item.artists[0].name}{item.album.name}</Brief>
                </Item>
                
              })}
            </List>
      </div>
    )
  }
}